/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package xml.timgiayto.utils;

/**
 *
 * @author mrnghiep
 */
public class CommonUtils {

    public static String INFORMATION_PATH = "xml/information.xml";
    public static String INFORMATION_CONVERT_PATH = "xml/information_convert.xml";
    public static String COMMENT_PATH = "xml/comment.xml";
    public static String INDEX_PATH = "index.jsp";
    public static String CREATE_PATH = "create.jsp";
    public static String ADMIN_INFORMATION_PATH = "admin-information.jsp";
    public static String ADMIN_LOGIN_PATH = "admin-login.html";
    public static String INFORMATION_FO_PATH = "xslt/informationFO.xsl";

    /**
     * Convert unsigned Vietnamese.
     * @param str
     * @return String
     */
    public static String convertVietnamese(String str) {
        str = str.toLowerCase();
        str = str.replaceAll("[áàạảãâấầậẩẫăắằặẳẵ]", "a");
        str = str.replaceAll("[éèẹẻẽêếềệểễ]", "e");
        str = str.replaceAll("[óòọỏõôốồộổỗơớờợởỡ]", "o");
        str = str.replaceAll("[úùụủũưứừựửữ]", "u");
        str = str.replaceAll("[íìịỉĩ]", "i");
        str = str.replaceAll("[đ]", "d");
        str = str.replaceAll("[ýỳỵỷỹ]", "y");
        return str;
    }

    /**
     * Convert Vietnamese Character.
     * @param str
     * @return String
     */
    public static String convertUTF8(String str) {
        if (null != str) {
            try {
                str = new String(str.getBytes("ISO-8859-1"), "UTF-8");
            } catch (java.io.UnsupportedEncodingException e) {
            }
        }
        return str;
    }
}
